package com.itstherules.jmsunit.expectation;

import javax.jms.Message;

import com.itstherules.jmsunit.expectation.JmsExpectation;
import com.itstherules.jmsunit.expectation.StringExpectation;

import junit.framework.Assert;


public final class TextEqualsExpectation implements JmsExpectation, StringExpectation {

	private final String expected;

	public TextEqualsExpectation(String expected) {
		new NotNullExpectation().compute(expected);
		this.expected = expected;
	}

	public void compute(Message actual) throws AssertionError {
		JmsMessageAndStringExpectation expectation = new JmsMessageAndStringExpectation(this);
		expectation.compute(actual);
	}
	
	public void compute(String actualText) throws AssertionError {
		Assert.assertEquals(expected, actualText);
	}
	
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("Text is equals (expected is ");
		buffer.append(expected);
		buffer.append(")");
		return buffer.toString();
	}

}
